// pages/balance/balance.js
const api = require('../../utils/http.js');
const app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		balance: '',
		detailed: []
	},
	goExchangeGold() {
		wx.navigateTo({
			url: '/pages/exchangeGold/exchangeGold?goldTotal='+this.data.jinbi
		})
	},

	//余额提现
	balance() {
		// wx.navigateTo({
		// 	url: '/pages/withdrawal/withdrawal?balance=' + this.data.balance
		// })

    	wx.navigateTo({
        url: '/pages/applyPresentation/applyPresentation?balance=' + this.data.balance
		})
    
	},
	showBalance() {
		let uid = app.globalData.uid;
		api.fetchApi('procedure_t', {
			p: `R2006005|${uid}|2`
		}).then(res => {
			const {code, results} = res.data
			if (code == 1) {
				this.setData({
					detailed: results
				})
			} else {
				wx.showToast({
					title: `${res.data.errorMsg}`,
					icon: 'none'
				})
			}
		})
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		this.setData({
			balance: options.balance,
      jinbi:options.jinbi
		})
		this.showBalance()
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
